package com.dw.widget.slideshow2.utils.log;

import android.content.Context;

/**
 * 通用日志类
 * @author daiyu
 *
 */
public class Log {

	public final static int LEVEL_NONE = 0;
	public final static int LEVEL_ERR = 1;
	public final static int LEVEL_DEBUG= 2;
	public final static int LEVEL_INFO = 3;
	public final static int LEVEL_FILE = 4;
	
	public static int LOGLEVEL = LEVEL_INFO;   // 默认显示所有打印日志
	
	public static void i(Context context, String tag, String msg)
	{
		if(LOGLEVEL < LEVEL_INFO)
		{
			return;
		}
		
		android.util.Log.i(tag, msg);
		
		if(LOGLEVEL >= LEVEL_FILE)
		{
			FileLog fl = FileLog.getInstance(context);
			if(fl != null)
			{
				fl.i(tag, msg);
			}
		}
	}
	
	public static void d(Context context, String tag, String msg)
	{
		if(LOGLEVEL < LEVEL_DEBUG)
		{
			return;
		}
		
		android.util.Log.d(tag, msg);

		if(LOGLEVEL >= LEVEL_FILE)
		{
			FileLog fl = FileLog.getInstance(context);
			if(fl != null)
			{
				fl.d(tag, msg);
			}
		}
	}
	
	public static void e(Context context, String tag, String msg)
	{
		if(LOGLEVEL < LEVEL_DEBUG)
		{
			return;
		}
		
		android.util.Log.e(tag, msg);
		
		if(LOGLEVEL >= LEVEL_FILE)
		{
			FileLog fl = FileLog.getInstance(context);
			if(fl != null)
			{
				fl.e(tag, msg);
			}
		}
	}
}
